package A13;


import javax.security.auth.Subject;
import java.util.List;


public class Instructor {
    private String instructorName; // 教师姓名
    private Department department; // 关联：1个系
    private List<Subject> taughtSubjects; // 关联：1~3门课程

    public Instructor(String instructorName) {
        this.instructorName = instructorName;
    }

    // 添加授课课程（限制最多3门）
    public void addTaughtSubject(Subject subject) {
        if (taughtSubjects == null) {
            throw new IllegalStateException("请先初始化taughtSubjects集合！");
        }
        if (taughtSubjects.size() >= 3) {
            throw new IllegalStateException("约束：教师最多教授3门课程！");
        }
        taughtSubjects.add(subject);
    }

    // getter/setter
    public String getInstructorName() {
        return instructorName;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public List<Subject> getTaughtSubjects() {
        return taughtSubjects;
    }

    public void setTaughtSubjects(List<Subject> taughtSubjects) {
        this.taughtSubjects = taughtSubjects;
    }
}